$(function(){
    // 导航当前样式动效
    var defaultStyleIdx = $('.rightNav li.now').index();
    var moveLen = $('.rightNav li').outerWidth(true);
    var moveEle = $('.rightNav .line');
    moveEle.animate({left:defaultStyleIdx*moveLen},500);
    $('.rightNav li:not(".line")').hover(function () {
        var idx = $('.rightNav li').index(this);
        moveEle.stop(true,true);
        moveEle.animate({left:idx*moveLen},500);
    },function () {
        moveEle.stop(true,true);
        moveEle.delay(500).animate({left:defaultStyleIdx*moveLen},1000);
    });
    // 右侧悬浮导航
    $(window).scroll(function(){
        var moveSc = $(this).scrollTop();
        if(moveSc>506){
            $('.fixedCon').css({position:'fixed',top:90})
        }else{
            $('.fixedCon').css({position:'absolute',top:596})
        }
    });

    var options = [
        [
            {width:384, height:343, top:0, left:417},
            {width:335, height:309, top:22, left:730},
            {width:259, height:231, top:56, left:930},
            {width:200, height:200, top:60, left:900},
            {width:335, height:309, top:22, left:170},
            {width:259, height:231, top:56, left:0},
            {width:200, height:200, top:60, left:10}
        ],
        [
            {zIndex:5,'opacity':1},
            {zIndex:4,'opacity':1},
            {zIndex:3,'opacity':1},
            {zIndex:2,'opacity':1},
            {zIndex:4,'opacity':1},
            {zIndex:3,'opacity':1},
            {zIndex:2,'opacity':1}
        ]
    ]
    var storefront = [
        [
            {width:'41.1%', top:0, left:'29.6%'},
            {width:'28.4%', top:80, left:'71.6%'},
            {width:'28.6%', top:80, left:0}
        ],
        [
            {zIndex:5,'opacity':1},
            {zIndex:4,'opacity':.6},
            {zIndex:4,'opacity':.6}
        ]
    ]
    zoomPic("#focus_Box_brand",options);//品牌荣誉
    zoomPic("#focus_Box_storefront",storefront);//品牌故事
    zoomPic("#focus_Box_store",storefront);//门店人气



    // 滚动动画
    var js_ani_eles = $('.js_ani');
    for(var i=0;i<js_ani_eles.length;i++){
        ani(js_ani_eles.eq(i),200);
    }
    // 定义动画执行函数
    function ani(id,scrMoveNum){
        var hei = $(window).height();
        var myId = id;
        var len = myId.length;
        doAddClass();
        function doAddClass(){
            for (var i = 0; i < len; i++) {
                var objTop = myId.eq(i).offset().top;
                var scrTop = $(this).scrollTop();
                var nowAni = objTop - scrTop - hei/2+scrMoveNum;
                if(nowAni<0){
                    myId.eq(i).addClass('animated');
                }
                if(nowAni<-hei){
                    myId.eq(i).removeClass('animated');
                }
            };
        }
        $(window).scroll(function(){
            doAddClass();
        });
    };


    // 总部支持轮播
    supportFn();
    function supportFn() {
        var timer = null;
        var num = 0;
        var ele = $('.supportLists');
        var eles = ele.find('li');
        var len = eles.length;
        var isTimer = false;
        timer = setInterval(function () {
            if(isTimer){
                return false;
            }
            num++;
            if(num>=len){
                num=0;
            }
            eles.removeClass('now').eq(num).addClass('now');
        },3000)
        eles.hover(function(){
            num = $(this).index();
            $(this).addClass('now').siblings('li').removeClass('now');
            isTimer = true;
        },function () {
            isTimer = false;
        });
    }
    
    
    
    
    
    
    
})
